/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package objects;

import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.math.Vector3f;


/**
 *
 * @author 100350
 */
public class Player extends CharacterControl{
    private boolean powerful = false, left = false, 
            right = false, up = false, down = false,
            alive = true;
    private long PTime;
    private String name;

    public long getPTime() {
        return PTime;
    }

    public void setPTime(long PTime) {
        this.PTime = PTime;
    }

    
    public boolean isAlive() {
        return alive;
    }

    public void setAlive(boolean alive) {
        this.alive = alive;
    }
    
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    private Vector3f direction;
    
    public boolean isPowerful() {
        return powerful;
    }

    public void setPowerful(boolean powerful) {
        this.powerful = powerful;
    }
    
    public Player(String name, CollisionShape shape, float stepHeight)
    {
        super(shape, stepHeight);
        this.name = name;
        direction = new Vector3f();
        setFallSpeed(30);
        setGravity(30);
    }
    
    public void setDirection(String direction, boolean isPressed)
    {
        if("Left".equals(direction)) {
            left = isPressed;
        }
        if("Right".equals(direction)) {
            right = isPressed;
        }
        if("Up".equals(direction)) {
            up = isPressed;
        }
        if("Down".equals(direction)) {
            down = isPressed;
        }
    }
    
    public void walk(Vector3f camDir, Vector3f camLeft)
    {
        direction.set(0,0,0);
        if (left) {
            direction.addLocal(camLeft);
        }
        if (right) {
            direction.addLocal(camLeft.negate());
        }
        if (up) {
            direction.addLocal(camDir);
        }
        if (down) {
            direction.addLocal(camDir.negate());
        }
        setWalkDirection(direction);
    }
}
